import { ElLoading } from 'element-plus'

export const useLoading = () => {
  let loadingInstance: any
  function loadingStart() {
    loadingInstance = ElLoading.service({
      body: true,
      fullscreen: true,
      text: '拼命加载中',
      customClass: 'loading-class',
      background: 'rgba(255, 255, 255, 0.3)'
    })
  }
  function loadingEnd() {
    loadingInstance?.close()
    loadingInstance = null
  }
  return {
    loadingStart,
    loadingEnd
  }
}
